# Maintainer: Andrew Sun <adsun701@gmail.com>

_realname=ffcall
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=2.5
pkgrel=1
pkgdesc="C library for implementing foreign function calls in embedded interpreters (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="https://www.gnu.org/software/libffcall/"
license=('GPL2')
depends=("${MINGW_PACKAGE_PREFIX}-libwinpthread-git")
makedepends=("${MINGW_PACKAGE_PREFIX}-autotools"
             "${MINGW_PACKAGE_PREFIX}-cc")
options=('!makeflags')
source=("https://ftp.gnu.org/gnu/libffcall/lib${_realname}-${pkgver}.tar.gz")
sha256sums=('7f422096b40498b1389093955825f141bb67ed6014249d884009463dc7846879')

build() {
  mkdir -p "${srcdir}"/build-${MSYSTEM} && cd "${srcdir}"/build-${MSYSTEM}

  ../lib${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-static \
    --enable-shared

  make
}

check() {
  cd "${srcdir}"/build-${MSYSTEM}
  make check || true
}

package() {
  cd "${srcdir}"/build-${MSYSTEM}
  install -d "${pkgdir}"${MINGW_PREFIX}/share/{man,doc/ffcall}
  make install DESTDIR="${pkgdir}" htmldir=${MINGW_PREFIX}/share/doc/ffcall
}
